/*
	拓扑图组件基类
*/
define(
	[
		'require',
		'zrender/Group'
	],
	function(require) {
		"use strict";
		var Group = require('zrender/Group');

		var Component = Ember.Object.extend(Ember.Evented, {
			x: 0,

			y: 0,

			container: null,

			groupName: "group",

			init: function() {
				var container = this.container;
				if (!container) {
					return;
				}

				if (!this.group) {
					this.group = new Group();
				}

				this.zr = container.zr;

				container[this.groupName].addChild(this.group);
			},

			position: function(x, y) {
				var zr = this.zr,
					g = this.group;

				this.x = x;
				this.y = y;

				if (zr) {
					// g.position[0] = x;
					// g.position[1] = y;
					var defer = zr.animate(g, null, false);
					defer.when(200, {
							position: [x, y]
						})
						.start();
					return defer;
				}
			},

			render: function() {
				throw "must implement render method";
			},

			destroy: function() {
				this._super();
				this.container[this.groupName].removeChild(this.group);
				this.group = null;
			}
		});

		return Component;
	}
);